//
//  USPhotoSectionHeader.m
//  us
//
//  Created by karry on 2025/4/11.
//

#import "USPhotoSectionHeader.h"

@interface USPhotoSectionHeader ()


@end
@implementation USPhotoSectionHeader

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        UILabel *label = [[UILabel alloc] init];
        label.font = [UIFont us_groupFont];
        label.textColor = UIColor.labelColor;
        [self addSubview:label];
        _titleLabel = label;
        [label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(16);
            make.centerY.mas_equalTo(self);
        }];
        
        self.chooseBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        self.chooseBtn.hidden = YES;
        [self addSubview:self.chooseBtn];
        [self.chooseBtn setTitleColor:UIColor.labelColor forState:0];
        [self.chooseBtn setTitle:@"全选" forState:0];
        [self.chooseBtn.titleLabel setFont:[UIFont systemFontOfSize:14]];
        [self.chooseBtn addTarget:self action:@selector(chooseAction) forControlEvents:UIControlEventTouchUpInside];
        [self.chooseBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(self);
            make.right.mas_equalTo(-16);
        }];
        
    }
    return self;
}
- (void)setEdit:(BOOL)edit{
    _edit = edit;
    
    self.chooseBtn.hidden = !edit;
}

- (void)chooseAction {
    if (self.chooseBlock) {
        self.chooseBlock();
    }
}
 

@end
